/*
 * @Author: your name
 * @Date: 2021-04-29 11:45:55
 * @LastEditTime: 2021-04-29 16:33:07
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \源码c:\Users\EDZ\Desktop\js学习\移动端h5\rem.js
 */
var documentElement = document.documentElement;
console.log(documentElement)
function callback() {
    var clientWidth = documentElement.clientWidth;
    console.log(clientWidth)
    // 屏幕宽度大于780，不在放大
    clientWidth = clientWidth < 640 ? clientWidth : 640;
    documentElement.style.fontSize = clientWidth / 10 + 'px';
}

document.addEventListener('DOMContentLoaded', callback);
window.addEventListener('orientationchange' in window ? 'orientationchange' : 'resize', callback);